package com.leslie.app.service.impl;

import com.leslie.app.entity.User;
import com.leslie.app.mapper.UserMapper;
import com.leslie.app.service.UserService;
import com.leslie.app.utils.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByUserName(String username) {
       return userMapper.findByUserName(username);
    }

    @Override
    public List<User> findAll() {
        return userMapper.findAll();
    }

    @Override
    public void register(String username, String password) {
        String md5Password = Md5Util.getMD5String(password);
        userMapper.add(username, md5Password);
    }

}
